package com.kedacom.ctsp.authority.service;

import com.kedacom.ctsp.authority.entity.ResourceSettingRelation;
import com.kedacom.ctsp.authority.entity.SettingForType;
import com.kedacom.ctsp.authz.entity.AuthResource;
import com.kedacom.ctsp.authz.entity.ResourceEnum;
import com.kedacom.ctsp.web.service.CrudService;

import java.util.List;
import java.util.Set;

/**
 * 资源分配service
 *
 * @author sunchenjie
 * @date 2017/11/12 0012
 */
public interface ResourceSettingRelationService extends CrudService<ResourceSettingRelation, String> {

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    int delete(List<String> ids);

    /**
     * 按type+id 删除设置
     *
     * @param settingForType
     * @param settingForId
     */
    void deleteBySettingFor(SettingForType settingForType, String settingForId);

    /**
     * 按type+id+resourceIds 删除设置
     *
     * @param settingForType
     * @param settingForId
     */
    void deleteBySettingFor(SettingForType settingForType, String settingForId, List<String> resourceIds);

    /**
     * 批量merge
     *
     * @param
     * @return
     */
    List<String> batchMerge(SettingForType settingForType, String settingForId, List<ResourceSettingRelation> rss);

    /**
     * 批量merge
     *
     * @param
     * @return
     */
    List<String> batchAdd(SettingForType settingForType, String settingForId, List<ResourceSettingRelation> rss);


    /**
     * 根据角色查询
     *
     * @param uid
     * @param deptId
     * @param roleIds
     * @param resourceEnum
     * @return
     */
    Set<AuthResource> getAuthResourcesByRoles(String uid, String deptId, Set<String> roleIds, ResourceEnum resourceEnum);

    /**
     * 根据部门查询
     *
     * @param deptId
     * @param configSource
     * @return
     */
    Set<AuthResource> getAuthResourcesByDid(String deptId, ResourceEnum configSource);

    Set<AuthResource> getAuthResourcesByDids(Set<String> deptCodes, ResourceEnum configSource);

    Set<AuthResource> getAuthResourcesByRoles(Set<String> roleIds, ResourceEnum configSource);

    Set<AuthResource> getAuthResourcesByUser(String uid, ResourceEnum source);

    Set<AuthResource> convertResources(List<ResourceSettingRelation> resourceSettings, ResourceEnum source);
}
